<div class="menu">
<?php  echo $this->Form->menu($this->Access->getMy('id'),$this->Access->getMy('group_id'));?>
</div>
<div class="planeaciones form">
<?php echo $this->Form->create('Planeacione');?>
	<fieldset>
 		<div align="left"><?php echo $this->Html->image('edit_actividad_titulo.png', array('alt'=> __('Editar Actividad', true), 'border' => '0'));?></div>
        <div align="right"><?php echo $this->Html->link($this->Html->image('regresar.png', array('alt'=> __('Regresar', true), 'border' => '0')),
													'../planeaciones/aprobaciones/',array('escape' => false));?></div>
        <h4><?php //echo "Usuario: ".$users[$user_id]; ?></h4>
 		
 		<?php 			
 			$grupo_usuario = $this->Access->getMy('group_id');
 			$observacion_activa=false; $eliminar = false;
 			if($users['User']['group_id']==$grupo_usuario){ // Estoy viendo mi calendario
 				$campos_aprobacion = false;
 				$disable=false;
 				$eliminar = true;
 				if($this->Form->value('Planeacione.estado')!="Programado"){
 					$observacion_activa=true;
 				}
 			}else{
 				$campos_aprobacion = true;
 				$disable=true; 				
 			} 			
 		?> 	
 		
 		<tr><div align="right"> 			
 				<?php 
 					if($eliminar){ 				
	 					$id = $this->Form->value('Planeacione.id');
	 					$tipo = $this->Form->value('Planeacione.tipo_actividad');?>
		 		    	<td> <?php echo $this->Html->link($this->Html->image('delete_actividad.png', array('alt'=> __('Eliminar', true), 'border' => '0')),
	 					                         '../planeaciones/delete/'.$id,array('escape' => false));?>			         
	                   </td>
	    </div></tr>	
 		<table class="tabla_formulario">
  				 
	               	<tr> 
	                <td colspan="4"><?php echo $this->Form->input('event_date',array('label'=>'Fecha de la actividad', 'disabled'=>$disable));?></td>			
	 				<?php 
 					}else{
 						$anio = substr($this->Form->value('Planeacione.event_date'),0,4);?>
 					<td><?php 
 							$mes = substr($this->Form->value('Planeacione.event_date'),5,2);
 						?>
 					</td>
 				
 					<?php 
 					}
 				?>
 				<td></td>
 			</tr>
 			<tr>
 				<td colspan="1"><?php 						 
 						 echo $this->Form->select('actividade_id', array($actividades), $actividad_activa, array('disabled'=>$disable), false); ?>
 						</td>
 				<td><?php 						 
 						echo $this->Form->input('enfasis',array('disabled'=>$disable));
 					?>
 				</td>
 			</tr>
 			<tr>	
 				<td colspan="1"><?php 
 						echo $this->Form->label('Actores');
 						echo $this->Form->input('centro_apoyo_escolare_id', array( 'type' => 'select', 'options'=>$centroApoyoEscolares, 'selected'=>$actores_activos, 'multiple' => true, 'disabled'=>$disable, 'label'=>'Centro Apoyo Escolar'));
					?>
				</td> 							
 				
 				<td><?php
 						echo $this->Form->label('Descripci&oacute;n'); 
 						echo $this->Form->textarea('descripcion',array('disabled'=>$disable));
 					?>
 				</td> 
 			</tr>
 			<tr> 			
 				<td colspan="1"><?php
 						echo $this->Form->label('Recursos'); 
 						echo $this->Form->textarea('recursos',array('disabled'=>$disable));
 					?>
 				</td>
 				<td><?php
 						echo $this->Form->label('Resultados Esperados'); 
 						echo $this->Form->textarea('recursos_esperados',array('disabled'=>$disable));?>
 				</td>
 			</tr>
 	<?php 
 		if($observacion_activa){
 			?>
 			<tr> 		
 				<td colspan="1"><?php echo $this->Form->input('observacion',array('disabled'=>true));?></td>
 			</tr>
 			<?php echo $this->Form->input('estado', array('type'=>'hidden', 'value'=>'Programado')); ?>	
 			<?php 
 		} 			
		if($campos_aprobacion){
			?>
			<tr>
				<td><?php echo $this->Form->input('estado');?></td>
				<td colspan="1"><?php echo $this->Form->input('observacion');?></td>
			</tr>
			<?php 
			//Usuario aprobador
			echo $this->Form->input('user_aprobador_id', array('type'=>'hidden', 'value'=>$user_id));
			echo $this->Form->input('caes_aprobados', array('type'=>'hidden', 'value'=>$caes_aprobados));
			echo $this->Form->input('fecha', array('type'=>'hidden', 'value'=>$this->Form->value('Planeacione.event_date')));
			echo $this->Form->input('editando', array('type'=>'hidden', 'value'=>true));			
		}
	?>
	</table>
	</fieldset>
<?php echo $this->Form->input('id', array('type'=>'hidden', 'value'=>$this->Form->value('Planeacione.id'))); ?>
<?php echo $this->Form->input('user_id', array('type'=>'hidden', 'value'=>$this->Form->value('Planeacione.user_id'))); ?>
<?php echo $this->Form->end(__('Actualizar', true));?>
</div>
